<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      xmlns:c="http://www.w3.org/1999/XSL/Transform">
<head>
    <meta charset="UTF-8">
    <title>T_TaskShow</title>
    <link th:href="@{/css/ui.jqgrid.css}" href="../static/css/ui.jqgrid.css" rel="stylesheet">
    <link th:href="@{/css/ugly-table.css}" href="../static/css/ugly-table.css" rel="stylesheet">
    <link th:href="@{/css/bootstrap.min.css}" href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link th:href="@{/css/flat-ui.css}" href="../static/css/flat-ui.css" rel="stylesheet">
    <link th:href="@{/css/signin.css}" href="../static/css/signin.css" rel="stylesheet">

    <!--<script type="text/javascript">-->
        <!--function setCookie(name,value) {-->
            <!--var expc=new Date();-->
            <!--exp.setTime(exp.getTime()+24*60*6*1000);-->
            <!--document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();-->
        <!--}-->
        <!--function getCookie(name) {-->
            <!--var regExp =new RegExp("^|"+name+"=([^;]*)(;|$)");-->
            <!--var arr =document.cookie.match(regExp);-->
            <!--if(arr==null)-->
                <!--return null;-->
            <!--return unescape(arr[2]);-->
        <!--}-->
    <!--</script>-->
</head>
<!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">-->

<body th:inline="text">

<style>
    body {
        min-height: 2000px;
        padding-top: 70px;
    }
    .pageContent{
        width: auto;
        height: 800px;
    }
</style>
<!--顶部导航栏-->
<div th:include="t-head :: t-head"></div>
<!--主体-->
<div class="pageContainer">
    <!--正文内容-->
    <div class="pageContent">
        <h4>我的课题</h4>
       <p sec:authentication="name"> </p>
        <div>


        <div class="panel panel-default">
            <div class="panel-heading">
                <form  th:action="@{/teacher/t_FindTask}" action="/teacher/t_FindTask"  method="post">
                    <div class="form-inline">
                        <label>课题类型：</label>
                        <select id="tasktypeSelection" name="tasktypeSelection"class="form-control" > <!--onclick="setCookie('tasktypeSelection',this.selectedIndex)"-->
                            <option value="全部" th:selected="${tasktypeSelection_A1}">--全部--</option>
                            <option value="系统设计" th:selected="${tasktypeSelection_A2}">系统设计</option>
                            <option value="算法设计" th:selected="${tasktypeSelection_A3}">算法设计</option>
                            <option value="软件开发" th:selected="${tasktypeSelection_A4}">软件开发</option>
                        </select>
                        <label>审核状态：</label>
                        <select id="taskstateSelection" name="taskstateSelection"class="form-control" >
                            <option value="全部" th:selected="${taskstateSelection_B1}">--全部--</option>
                            <option value="待审核" th:selected="${taskstateSelection_B2}">待审核</option>
                            <option value="已通过"th:selected="${taskstateSelection_B3}">已通过</option>
                            <option value="未通过"th:selected="${taskstateSelection_B4}">未通过</option>
                        </select>
                        <button  type="submit" id="find_btn" class="btn btn-primary" >查询</button>
                    </div>
                </form>
            </div>

            <!--模态框-->
            <div>
                <!--删除模态框-->
                <div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                        aria-hidden="true">×
                                </button>
                                <h7 class="modal-title" id="myModalLabel">删除记录</h7>
                            </div>
                            <div class="modal-body">
                                <h7>您要从数据库中删除该课题吗？</h7>
                                <form th:action="@{/teacher/t_TaskDelete}" action="/teacher/t_TaskDelete"  method="post">
                                    <input type="hidden" id="del_taskid" name="del_taskid" value="del_taskid"/>
                                    <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
                                    <button type="submit" class="btn btn-primary" >确认</button>
                                </form>
                            </div>
                            <div class="modal-footer">
                            </div>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->

                <!--查看详情模态框-->
                <div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                        aria-hidden="true">×
                                </button>
                                <h7 class="modal-title" id="myModalLabel">查看课题详情</h7>
                            </div>
                            <div class="modal-body">
                                <form th:action="@{/teacher/t_ShowTaskDetail}" action="/teacher/t_ShowTaskDetail"  method="post">
                                    <input type="hidden" id="detail_task" name="detail_task" value="555"/>
                                    <div class="form-group form-inline">
                                        <label for="show_taskid">课题编号</label>
                                        <input type="text" id ="show_taskid" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_taskname">课题名称</label>
                                        <input type="text" id ="show_taskname" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_tutorname">课题导师</label>
                                        <input type="text" id ="show_tutorname" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_tasktype">课题类型</label>
                                        <input type="text" id ="show_tasktype" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_taskrate">课题级别</label>
                                        <input type="text" id ="show_taskrate" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_taskrate">可选人数</label>
                                        <input type="text" id ="show_taskmaxchoose" value="" readonly="readonly">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="show_taskdescrib">课题描述</label>
                                        <input type="text" id ="show_taskdescrib" value="" readonly="readonly">
                                    </div>

                                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>

                                    <!--<button type="submit" class="btn btn-primary" >确认</button>-->
                                </form>
                            </div>
                            <div class="modal-footer">
                            </div>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->

                <!--编辑模态框-->
                <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                        aria-hidden="true">×
                                </button>
                                <h7 class="modal-title" id="myModalLabel"> 修改课题</h7>
                            </div>
                            <div class="modal-body">
                                <form th:action="@{/teacher/edittask}" action="/teacher/edittask"  method="post">
                                    <!--<input type="hidden" id="taskid" name="taskid" value="111"/>-->
                                    <div class="form-group form-inline">
                                        <label for="edit_taskid">课题编号</label>
                                        <input type="text" id ="edit_taskid" name ="edit_taskid"value="" readonly="readonly" >
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="edit_taskname">课题名称</label>
                                        <input type="text" id ="edit_taskname" name ="edit_taskname"  value="" >
                                    </div>

                                    <div class="form-group form-inline">
                                        <label style="display: none" for="edit_tutorname">课题导师</label>
                                        <input style="display: none" type="text" id ="edit_tutorname" name="edit_tutorname" value="" readonly="readonly" >
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="edit_tasktype">课题类型</label>
                                        <input type="text" id ="edit_tasktype" name="edit_tasktype" value="" >
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="edit_taskrate">课题级别</label>
                                        <input type="text" id ="edit_taskrate" name="edit_taskrate" value="" >
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="edit_taskrate">可选人数</label>
                                        <input type="text" id ="edit_taskmaxchoose" name="edit_taskmaxchoose" value="">
                                    </div>

                                    <div class="form-group form-inline">
                                        <label for="edit_taskdescrib">课题描述</label>
                                        <input type="text" id ="edit_taskdescrib" name ="edit_taskdescrib" value="">
                                    </div>

                                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                                    <button type="submit" class="btn btn-primary" >确认</button>
                                </form>
                            </div>
                            <div class="modal-footer">
                            </div>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->

                <center>
                    <table id="mainTable" border="1" data-toggle="table" class="bordered">
                        <tr>
                            <!--<th>ID</th>-->
                            <th>课题编号</th>
                            <th>课题名称</th>
                            <!--           <th>学生姓名</th> -->
                            <!--<th>导师姓名</th>-->
                            <th>状态</th>
                            <th>查看详情</th>
                            <!--<th>关闭</th>-->
                            <th>修改</th>
                            <th>删除</th>
                        </tr>
                        <tr id ="task_tr" th:each="task,list:${initdata}">
                            <!--<td id="table_id" th:text="${list.size+1}"></td>-->
                            <td id="table_taskid" th:text="${task.taskid}" class="table_taskid" ></td>
                            <td id="table_taskname" th:text="${task.taskname}"></td>
                            <td style="display: none" id="table_tutorname" th:text="${task.tutorname}"></td>
                            <td id="table_taskstate" th:text="${task.taskstate}"></td>
                            <td style="display:none" id="table_tasktype" th:text="${task.tasktype}"></td>
                            <td style="display:none" id="table_taskrate" th:text="${task.taskrate}"></td>
                            <td style="display:none" id="table_taskdescrib" th:text="${task.taskdescrib}"></td>
                            <td style="display:none" id="table_taskmaxchoose" th:text="${task.taskmaxchoose}"></td>
                            <td><button id="show" class='btn btn-link' data-toggle='modal'  data-target='#detailModal' onclick="showdetail(this)">查看详情</button></td>
                            <td><button id="edit" class='btn btn-link' data-toggle='modal' data-target='#editModal' onclick="edit(this)">编辑课题</button></td>
                            <td><button id="delete" class='btn btn-link'  data-toggle='modal' data-target='#delModal' onclick="del(this)" >删除课题</button></td>
                        </tr>
                    </table>
                </center>
            </div>
        </div>
    </div>
</div>
</div>
<!--底部页脚部分 -->
<div class="footer">
    <!--<p class="text-center">
    2017 &copy; 浙江工商大学
    </p>-->
</div>
</div>

<script type="text/javascript">
    //    $(function () { $('#myModal').modal({
    //        keyboard: true
    //    })});


//    var selectedIndex =getCookie("tasktypeSelection");
//    if (selectedIndex!=null){
//        document.getElementById("tasktypeSelection").selectedIndex=selectedIndex;
//    }

    /**
     * 删除选课
     */
    function del(obj) {
        task = $(obj).parents("tr").find("#table_taskid").text();
        document.getElementById("del_taskid").value= task;
    }

    /**
     * 选课
     */
    function add(obj) {
        document.getElementById("addtomy_taskid").value=$(obj).parents("tr").find("#table_taskid").text();
        document.getElementById("addtomy_taskname").value=$(obj).parents("tr").find("#table_taskname").text();
        document.getElementById("student_id").value =$("#author").name;

    }

    /**
     * 查看课题详情
     */
    function showdetail(obj) {
        document.getElementById("show_taskid").value=$(obj).parents("tr").find("#table_taskid").text();
        document.getElementById("show_taskname").value=$(obj).parents("tr").find("#table_taskname").text();
        document.getElementById("show_tasktype").value=$(obj).parents("tr").find("#table_tasktype").text();
        document.getElementById("show_taskrate").value=$(obj).parents("tr").find("#table_taskrate").text();
        document.getElementById("show_tutorname").value=$(obj).parents("tr").find("#table_tutorname").text();
        document.getElementById("show_taskdescrib").value=$(obj).parents("tr").find("#table_taskdescrib").text();
        document.getElementById("show_taskmaxchoose").value=$(obj).parents("tr").find("#table_taskmaxchoose").text();


    }
    function edit(obj) {
        document.getElementById("edit_taskid").value=$(obj).parents("tr").find("#table_taskid").text();
        document.getElementById("edit_taskname").value=$(obj).parents("tr").find("#table_taskname").text();
        document.getElementById("edit_tasktype").value=$(obj).parents("tr").find("#table_tasktype").text();
        document.getElementById("edit_taskrate").value=$(obj).parents("tr").find("#table_taskrate").text();
        document.getElementById("edit_tutorname").value=$(obj).parents("tr").find("#table_tutorname").text();
        document.getElementById("edit_taskdescrib").value=$(obj).parents("tr").find("#table_taskdescrib").text();
        document.getElementById("edit_taskmaxchoose").value=$(obj).parents("tr").find("#table_taskmaxchoose").text();


    }

//    function setselection() {
////        document.getElementById("tasktypeSelection").value=$(obj).parents("tr").find("#tasktypeSelection").value;
//        document.getElementById("tasktypeSelection").value=$(obj).find("#tasktypeSelection").value;
//
//    }


    $("#add_btn").click(function () {

    });
    $(function(){
        $(window).resize(function(){
            $("#aTable").setGridWidth($(window).width());
        });
    });
</script>
<script th:src="@{/js/bootstrap.min.js}" src="../static/js/bootstrap.min.js"></script>
<script th:src="@{/js/jquery-3.1.1.min.js}" src="../static/js/jquery-3.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script th:src="@{/js/flat-ui.min.js}" src="../static/js/flat-ui.min.js"></script>
</body>
</html>
<!--<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>-->
<script src="//cdn.bootcss.com/jquery/3.0.0-beta1/jquery.min.js"></script>
<script src="//cdn.bootcss.com/jqgrid/4.6.0/js/i18n/grid.locale-en.js"></script>
<script src="//cdn.bootcss.com/jqgrid/4.6.0/js/jquery.jqGrid.min.js"></script>
